#! /usr/bin/env node
const fs = require("fs");
const curPath = process.cwd()+"/";
const fileData = JSON.parse(fs.readFileSync("list.json","utf-8"));
const com = process.argv[2];
if(com==="list.json"){
    if(!fs.existsSync(curPath+fileData.dirname)){
        fs.mkdirSync(curPath+fileData.dirname)
    }
    createFile(fileData.children,curPath+fileData.dirname+"/")
}else{
    console.log("必须写入list.json");
}
function createFile(data,src){
    data.forEach(item=>{
        if(item.dirname){
            fs.mkdirSync(src+item.dirname)
            if(item.children){
                createFile(item.children,src+item.dirname+"/")
            }
        }else{ 
            fs.writeFileSync(src+item.filename,"aaa")
        }
    })
}
